package nf.action;

import nf.dao.CellPhoneDao;
import nf.dao.CellPhoneDaoImpl;
import nf.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/ajaxServlet")
public class ajaxServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String name = request.getParameter("kk");
        //System.out.println(name+"zzz");
        CellPhoneDao dao = new CellPhoneDaoImpl();
        User us = dao.selectByUsname(name);
        PrintWriter pw = response.getWriter();
        //System.out.println(us);
        if(us!=null){
            pw.write("已被注册");
        }else{
            pw.write("可注册");
        }
    }
}
